const express = require('express');
const router = express.Router()

const { publishPost, getPostData, getCommunityPostData, getPostDetailData, getHotPostData, getUserPostData } = require('../../controller/web/PostController');
const { createUploadMiddleware } = require('../../middleware/UploadImageMiddleware')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')
// 导入验证禁言状态中间件
const checkMuteStatusMiddleware = require('../../middleware/checkMuteStatusMiddleware')
// 导入分页中间件
const paginationMiddleware = require('../../middleware/paginationMiddleware');

// 获取攻略数据
router.get('/post', paginationMiddleware, getPostData)

// 获取社区攻略数据
router.get('/post/community', paginationMiddleware, getCommunityPostData)

// 获取热门攻略数据
router.get('/post/hot', getHotPostData)

// 获取攻略详情数据
router.get('/post/detail/:id', getPostDetailData)

//发布攻略
router.post('/post/publish', checkTokenMiddleware, checkMuteStatusMiddleware, publishPost)

// 上传攻略图片
const uploadPostImages = createUploadMiddleware('Post')
router.post('/post/upload', checkTokenMiddleware, uploadPostImages)

// 获取用户个人发布的攻略数据
router.get('/post/user/:id', checkTokenMiddleware, getUserPostData)

module.exports = router